package com.example.task1.ui.AllService.volunteer;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.VolunteerBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class VolunteerAdapter extends BaseAdapter<VolunteerBean.RowsDTO> {

    private Context context;
    private List<VolunteerBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvTitle;
    private TextView tvUndertaker;
    private TextView tvRequireText;
    private TextView tvDetail;
    private TextView tvStartAt;

    public VolunteerAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<VolunteerBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.volunteerlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<VolunteerBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, VolunteerBean.RowsDTO date) {
        tvDetail.setText("活动详情：" + date.getDetail());
        tvRequireText.setText("报名要求：" + date.getRequireText());
        tvStartAt.setText("----" + date.getStartAt());
        tvTitle.setText(date.getTitle());
        tvUndertaker.setText("承办单位：" + date.getUndertaker());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        tvTitle = view.findViewById(R.id.tv_title);
        tvUndertaker = view.findViewById(R.id.tv_undertaker);
        tvRequireText = view.findViewById(R.id.tv_requireText);
        tvDetail = view.findViewById(R.id.tv_detail);
        tvStartAt = view.findViewById(R.id.tv_startAt);
    }
}
